//Sunday, December 06 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

long long dp[60];
class CorporationSalary
{
public:
	long long totalSalary(vector <string> relations)
	{
		N = relations.size();
		memset(dp, -1, sizeof(dp));
		long long ret = 0;
		for(int i=0; i<N; i++)
			ret += solve(relations, i);
		return ret;
	}
	long long solve(vector<string> relations, int n)
	{
		if(dp[n] != -1)
			return dp[n];
		dp[n] = 0;
		for(int i=0; i<N; i++)
			if(relations[n][i] == 'Y')
				dp[n] += solve(relations, i);
		if(dp[n] == 0)
			dp[n] = 1;
		return dp[n];
	}
	int N;
};
